<?php
session_start(); 
// Connect to the Database
include("includes/connect.php");
include("functions/registration_functions.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><!-- InstanceBegin template="/Templates/Main-Template.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>Star Map Mobile</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {color: #CCCCCC}
-->
</style>
</head>

<body class="oneColFixCtrHdr">

<div id="container">
  <div id="header"><a href="index.php">home</a> | <a href="http://www.bmcstudiosllc.com/starmap/forum/">forum</a> | <a href="news.php">news</a> | <a href="download.php">download</a> | <a href="account.php">account</a> | <a href="register.php">register</a>
    <!-- end #header -->
  </div>
  <div id="mainContent">
    <table width="100%" border="1" bordercolor="#DDDDDD" cellpadding="10" bgcolor="#333333">
  <tr>
    <td width="750" height="200"><div align="center"><img src="images/smmbanner.png" alt="smm" width="750" height="200"></div></td>
  </tr>
  <tr>
    <td height="100" width="750"><div align="center" class="style1">
      <p>Developed by University of Miami Undergraduate Students</p>
        <p>Joey Kadin, Brandon Calabro, Mychal Sligh, Alex Alvarez</p>
      </div></td>
  </tr>
  <tr>
    <td><!-- InstanceBeginEditable name="MainContent" -->
<?php if(isset($_SESSION['ADMIN']) && isset($_SESSION['USER'])){ 

include("functions/user_functions.php");

?>
<div align="center" class="NewsHeading">Admin Panel</div>

<br>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
    
    	<table width="100%" border="0" cellspacing="5" cellpadding="5">
  <tr>
    <td colspan="2"><font class="UserTableFont_HB">Welcome, <?php print $_SESSION['ADMIN']; ?> </font></td>
    </tr>
  <tr>
    <td width="50%"><div align="center" class="UserTableFont_B">Current Location</div></td>
    <td width="50%"><div align="center" class="UserTableFont_B">Current Email</div></td>
  </tr>
  <tr>
    <td><div align="center" class="UserTableFont">
      <table width="50%" border="1" cellpadding="3" cellspacing="3" bgcolor="#191919">
        <tr>
          <td width="43%">Latitude:</td>
          <td width="57%"><?php print $uGPS_Lat; ?></td>
        </tr>
        <tr>
          <td>Longitude:</td>
          <td><?php print $uGPS_Long; ?></td>
        </tr>
      </table>
    </div></td>
    <td>
    <div align="center" class="UserTableFont">
      <table width="50%" border="1" cellpadding="3" cellspacing="3" bgcolor="#191919">
        <tr>
          <td><div align="center" class="UserTableFont"><?php print $uEmail; ?></div></td>
        </tr>
        <tr>
          <td><div align="center" class="UserTableFont"><a href="changeemail.php">Change Email</a></div></td>
        </tr>
      </table>
    </div>    </td>
  </tr>
  <tr>
    <td colspan="2"><div align="center" class="UserTableFont"><br><br><a href="changepass.php">Change Password</a></div></td>
  </tr>
  <tr>
    <td colspan="2"><div align="center" class="UserTableFont_B">Update News Feed</div>
    <div align="center">
    <form action='adminpanel.php' method='post'>
    <table align="center"width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
      <div align="center">
        <textarea rows='10' name='news' cols='50'></textarea>
        </div></td>
    </tr>
  <tr>
    <td><div align="center"><input type="hidden" value="1" name="NEWS_FLAG" /><input type="submit" name="submit" value="Add News Article" /></div></td>
    </tr>
</table>
</form>
    </div>
    </td>
    </tr>
</table>

    
    </td>
  </tr>
</table>

<?php
	if($_POST['NEWS_FLAG'] == 1)
	{
			$News = $_POST['news'];
			
			putenv("TZ=US/Eastern");
			$date = date("F j, Y, g:i a");
			
			$UpdateNewsFeed = "INSERT INTO `news_feed` (`date`, `news`) VALUES ('$date', '$News')";	     
			mysql_query($UpdateNewsFeed) or die("Could not update news feed");
			
		 	print "<font color='#FF0000'>You have added a news article!</font><br>";
	}
?>
    
<?php } else {

     	   // This will redirect the user to the index page where they must log in again!
 	   
 	   print "<p>User is NOT Authentic</p>";  
 	   print "<p>Redirecting...</p>";      
       // This will refresh the page with the new session started
       print "<META HTTP-EQUIV = 'Refresh' Content = '2; URL =index.php'>";  // May need a slash in front of index.php

}
?>
    <!-- InstanceEndEditable --></td>
  </tr>
</table>

	<!-- end #mainContent --></div>
  <div id="footer">
    <p>All rights reserved. Powered by <a href="http://www.bmcstudiosllc.com/">BMC Studios LLC.</a></p>
  <!-- end #footer --></div>
<!-- end #container --></div>
</body>
<!-- InstanceEnd --></html>
